package com.yuwubao.hz_International

import com.alipay.api.DefaultAlipayClient
import com.alipay.api.domain.AlipayTradeAppPayModel
import com.alipay.api.request.AlipayTradeAppPayRequest
import com.yuwubao.hz_International.entities.repository.GiftFansRepo
import com.yuwubao.hz_International.entities.repository.InviteRewardsConfigRepository
import com.yuwubao.hz_International.util.AlipayConfig
import org.junit.Test
import org.junit.runner.RunWith
import org.slf4j.LoggerFactory
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.test.context.junit4.SpringRunner
import javax.annotation.Resource

@SpringBootTest
@RunWith(SpringRunner::class)
class Test1 {

    val logger = LoggerFactory.getLogger(Test1::class.java)
    @Resource
    private lateinit var invateDao: InviteRewardsConfigRepository

    @Test
    fun test1() {
        val alipayClient = DefaultAlipayClient(AlipayConfig.URL, AlipayConfig.URL, AlipayConfig.PRIVATE_KEY, AlipayConfig.FORMAT
                , AlipayConfig.CHARSET, AlipayConfig.PUBLIC_KEY, AlipayConfig.SIGNTYPE)
        val payRequest = AlipayTradeAppPayRequest()
        val model = AlipayTradeAppPayModel()
        model.outTradeNo = "123123132131"
        model.timeoutExpress = "90m"
        model.totalAmount = "1.00"
        model.productCode = "QUICK_MSECURITY_PAY"
        payRequest.bizModel = model
        payRequest.notifyUrl = "http://www.allblux.xyz/app/demo"

        val res = alipayClient.sdkExecute(payRequest)
        logger.info(res.body)
    }

    @Resource private lateinit var giftFansRepo: GiftFansRepo
    @Test
    fun test2() {

        print(giftFansRepo.findByPhone(24,"13971282617"))
    }
}